home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / objeas3a / demos / tuidemo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-18  |  31.0 KB  |  1,294 lines

  1. //**************************************************************************
  2. //      This is a demo program to show how to use some of the features of
  3. //      the TUI libraries of the ObjectEase package. To compile and run this
  4. //      program create a project file including the files TUI30.LIB
  5. //      (use TUI40.LIB if you are using Borland C++ version 4.0) and
  6. //      TUIDEMO.CPP. Make sure that the files in the project are located where
  7. //      the project says they are. You may also need to modify the path to
  8. //      TUI.H in the #includes portion of this file.
  9. //
  10. //      BE SURE YOU ARE COMPILING FOR THE LARGE MEMORY MODEL!!!
  11. //**************************************************************************
  12.  
  13. #include "d:\tui\tui.h"
  14. #include <conio.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <mem.h>
  18. #include <alloc.h>
  19.  
  20. //*************************  FUNCTION PROTOTYPES  **************************
  21.  
  22. void initialize();
  23. void introscreen();
  24. void explainscreen();
  25. void windowdemo();
  26. void menudemo();
  27. void pulldowndemo();
  28. void stringdemo();
  29. void buttondemo();
  30. void checkboxdemo();
  31. void listboxdemo();
  32. void dirboxdemo();
  33. void textmousedemo();
  34. void wrapup();
  35.  
  36. //***************************  GLOBAL VARIABLES  ***************************
  37.  
  38. extern Mcursor the_mouse;
  39.  
  40. //**************************************************************************
  41. //              MAIN
  42. //**************************************************************************
  43.  
  44. void main()
  45. {
  46.     initialize();
  47.     introscreen();
  48.     explainscreen();
  49.     windowdemo();
  50.     menudemo();
  51.     pulldowndemo();
  52.     listboxdemo();
  53.     dirboxdemo();
  54.     stringdemo();
  55.     buttondemo();
  56.     checkboxdemo();
  57.     textmousedemo();
  58.     wrapup();
  59.  
  60.     settext(7,0);
  61.     cursoron();
  62.     clrscr();
  63.     puts("Thank you for previewing the ObjectEase library from");
  64.     puts("David S. Reinhart Associates");
  65.     exit(0);
  66. }
  67.  
  68. //**************************************************************************
  69. //              INITIALIZE
  70. //**************************************************************************
  71.  
  72. void initialize()
  73. {
  74.     char ch;
  75.  
  76. /*        if(farcoreleft()<=350000) {
  77.         puts("This demo requires a minimum of 350K free memory");
  78.         exit(0);
  79.         }
  80. */
  81.  
  82.     clrscr();
  83.     flushkeys();
  84.     if(!the_mouse.init()) {
  85.         puts("Mouse driver not found. If you have a mouse, press <ESC> now");
  86.         puts("to exit and load your mouse driver. Press any other key to continue.");
  87.         ch=getch();
  88.         if(ch==27)
  89.             exit(1);
  90.         }
  91.     cursoroff();
  92. }
  93.  
  94. //**************************************************************************
  95. //              INTROSCREEN
  96. //**************************************************************************
  97.  
  98. void introscreen()
  99. {
  100.     int done=0;
  101.     char ch;
  102.  
  103.     clear(32,1,1);
  104.     dlay(8);
  105.     smoved(37,1,7,14,1,"Welcome");
  106.     dlay(3);
  107.     smover(9,1,35,14,1,"To The World");
  108.     dlay(3);
  109.     smovel(11,79,40,14,1,"Of");
  110.     dlay(3);
  111.     smoveu(31,25,14,15,1,">>>  ObjectEase  <<<");
  112.  
  113.     Twindow creditwindow;
  114.     creditwindow.init(5,18,76,24,0,3,0,0);
  115.     creditwindow.setborder(DOUBLE);
  116.     creditwindow.zoom();
  117.     creditwindow.title(" DEMO ");
  118.     creditwindow.border();
  119.  
  120.     creditwindow.wprintc(2,15,3,"The ObjectEase 3.0 TUI Library Demo");
  121.     creditwindow.wprintc(3,15,3,"(c) Copyright 1992-1994 - David S. Reinhart Asociates");
  122.     creditwindow.wprintc(5,14,3,"Press <ENTER> to continue...");
  123.  
  124.     while(!done) {
  125.         smover(16,25,53,11,1,"***");
  126.         if(kbhit()) {
  127.             ch=getch();
  128.             if(ch==13) {
  129.                 ungetch(ch);
  130.                 done=1;
  131.                 continue;
  132.                 }
  133.             }
  134.         smoveu(53,16,5,11,1,"***");
  135.         if(kbhit()) {
  136.             ch=getch();
  137.             if(ch==13) {
  138.                 ungetch(ch);
  139.                 done=1;
  140.                 continue;
  141.                 }
  142.             }
  143.         smovel(5,53,25,11,1,"***");
  144.         if(kbhit()) {
  145.             ch=getch();
  146.             if(ch==13) {
  147.                 ungetch(ch);
  148.                 done=1;
  149.                 continue;
  150.                 }
  151.             }
  152.         smoved(25,5,16,11,1,"***");
  153.         if(kbhit()) {
  154.             ch=getch();
  155.             if(ch==13) {
  156.                 ungetch(ch);
  157.                 done=1;
  158.                 continue;
  159.                 }
  160.             if(ch==27) {
  161.                 clrscr();
  162.                 exit(0);
  163.                 }
  164.             }
  165.         }
  166.     clear(32,1,1);
  167. }
  168.  
  169. //*************************************************************************
  170. //              EXPLAINSCREEN
  171. //*************************************************************************
  172.  
  173. void explainscreen()
  174. {
  175.     char ch;
  176.  
  177.     Twindow mainwindow;
  178.     mainwindow.init(1,1,80,25,15,1,0,0);
  179.     mainwindow.title(" ObjectEase ");
  180.     mainwindow.show();
  181.     mainwindow.divider(HOR,DOUBLE,2);
  182.     printc(2,14,1,"Text Mode Features");
  183.  
  184.     dlay(18);
  185. //WINDOW
  186.     Twindow demowindow;
  187.     demowindow.init(10,5,20,10,0,3,1,9);
  188.     demowindow.zoom();
  189.     printat(11,12,14,1,"Windows");
  190.     dlay(18*2);
  191. //MENU
  192.     Tmenu demomenu;
  193.     itemarray items;
  194.  
  195.     _fstrcpy(items[1],"Item 1");
  196.     _fstrcpy(items[2],"Item 2");
  197.     _fstrcpy(items[3],"Item 3");
  198.  
  199.     demomenu.init(3,items,35,5,15,15,4,14,0,1,9);
  200.     demomenu.setborder(DOUBLE);
  201.     demomenu.show();
  202.     printat(39,12,14,1,"Menus");
  203.     dlay(18*2);
  204. //BUTTON
  205.     Tbutton button1;
  206.     button1.init(64,6," Start ",2);
  207.     Tbutton button2;
  208.     button2.init(64,8," Stop  ",3);
  209.  
  210.     button1.show(1);
  211.     button2.show(1);
  212.     printat(65,12,14,1,"Buttons");
  213.     dlay(18*2);
  214. //STRING
  215.     Tstring the_string;
  216.     Tdate the_date;
  217.  
  218.     the_string.init(20,18,15,0);
  219.     the_string.setincolors(14,0);
  220.     the_string.show();
  221.  
  222.     the_date.init(20,20);
  223.     the_date.setincolors(14,0);
  224.     the_date.show();
  225.  
  226.     printat(10,18,11,1,"Name: ");
  227.     printat(10,20,11,1,"Date: ");
  228.     printat(10,22,14,1,"String Input");
  229.     dlay(18*2);
  230. //CHECKBOX
  231.     Tcheckbox yesbox;
  232.     yesbox.init(60,18,15,1);
  233.     Tcheckbox nobox;
  234.     nobox.init(60,20,15,1);
  235.  
  236.     yesbox.show();
  237.     yesbox.check();
  238.  
  239.     nobox.show();
  240.  
  241.     printat(55,18,15,1,"Yes");
  242.     printat(55,20,15,1,"No ");
  243.     printat(55,22,14,1,"Check Boxes");
  244.     dlay(18*2);
  245.  
  246.     printc(24,15+128,1,"Press <ENTER> to continue");
  247.     flushkeys();
  248. getkey:
  249.     while(!kbhit());
  250.     ch=getch();
  251.     if(ch==27) {
  252.         clrscr();
  253.         exit(0);
  254.         }
  255.     if(ch!=13) {
  256.         flushkeys();
  257.         goto getkey;
  258.         }
  259. }
  260.  
  261. //*************************************************************************
  262. //              WINDOWDEMO
  263. //*************************************************************************
  264.  
  265. void windowdemo()
  266. {
  267.     char ch;
  268.  
  269.     clear(32,1,1);
  270.     dlay(12);
  271.     smover(12,1,37,14,1,"Windows");
  272.     dlay(18*2);
  273.     smover(12,37,74,14,1,"Windows");
  274.     clear(176,15,1);
  275.     dlay(18);
  276.  
  277.     printat(20,10,15,1,"With this simple piece of code...");
  278.     printat(25,12,15,1,"Twindow the_window;");
  279.     printat(25,13,15,1,"the_window.init(10,5,71,20,14,4,1,7);");
  280.     dlay(18*3);
  281.     printat(20,15,15,1,"You have created this window...");
  282.     dlay(18*3);
  283.  
  284.     Twindow demowindow;
  285.     demowindow.init(10,5,71,20,14,4,1,7);
  286.     demowindow.show();
  287.     dlay(18*3);
  288.  
  289.     printat(20,8,15,4,"Want to change the border?  Try this...");
  290.     printat(25,10,15,4,"the_window.setborder(DOUBLE);");
  291.     printat(25,11,15,4,"the_window.border();");
  292.     dlay(18*3);
  293.  
  294.     demowindow.setborder(DOUBLE);
  295.     demowindow.border();
  296.     dlay(18*3);
  297.  
  298.     printat(20,14,15,4,"Now to clear the window...");
  299.     printat(25,16,15,4,"the_window.fill();");
  300.     dlay(18*3);
  301.  
  302.     demowindow.fill();
  303.     dlay(18*3);
  304.  
  305.     printat(20,10,15,4,"Let's add a title. We'll call it Window 1.");
  306.     printat(25,12,15,4,"the_window.title(\"Window 1\");");
  307.     printat(25,13,15,4,"the_window.border();");
  308.     dlay(18*3);
  309.  
  310.     demowindow.title("Window 1");
  311.     demowindow.border();
  312.     dlay(18*3);
  313.     demowindow.fill();
  314.  
  315.     printat(20,10,15,4,"No, how about a heading instead of a title.");
  316.     printat(25,12,15,4,"the_window.divider(HOR,DOUBLE,2);");
  317.     printat(25,13,15,4,"the_window.wprintc(1,15,4,\"Window 1\");");
  318.     dlay(18*3);
  319.  
  320.     demowindow.title("");
  321.     demowindow.border();
  322.     demowindow.divider(HOR,DOUBLE,2);
  323.     demowindow.wprintc(1,15,4,"Window 1");
  324.     dlay(18*3);
  325.  
  326.     demowindow.hide();
  327.     clear(176,15,1);
  328.     dlay(18);
  329.  
  330.     printc(10,15,1,"You can display a window like this...");
  331.     printc(12,15,1,"the_window.show();");
  332.     dlay(18*3);
  333.  
  334.     demowindow.show();
  335.     dlay(18*2);
  336.     demowindow.hide();
  337.     clear(176,15,1);
  338.     dlay(18);
  339.  
  340.     printc(10,15,1,"Or ZOOM it like this...");
  341.     printc(12,15,1,"the_window.zoom();");
  342.     dlay(18*3);
  343.  
  344.     demowindow.zoom();
  345.     dlay(18*2);
  346.     printc(10,15,4,"Hide a window with this call...");
  347.     printc(12,15,4,"the_window.hide();");
  348.     dlay(18*3);
  349.  
  350.     demowindow.hide();
  351.     clear(176,15,1);
  352.     dlay(18*3);
  353.  
  354.     /*Twindow warray[8];
  355.     for(int i=0;i<8;i++) {
  356.         warray[i].init(18+(i*3),4+(i*2),20+(18+(i*3)),4+(4+(i*2)),i+1,i,1,7);
  357.         warray[i].setborder(DOUBLE);
  358.         warray[i].show();
  359.         }
  360.     Twindow newwindow;
  361.     newwindow.init(5,8,76,12,15,1,1,7);
  362.     newwindow.setborder(DOUBLE);
  363.     newwindow.zoom();
  364.     newwindow.wprintc(2,15,1,"Windows can overlap, and any underlying image is saved.");
  365.     dlay(18*4);
  366.  
  367.     newwindow.hide();
  368.     dlay(18);
  369.  
  370.     for(i=7;i>-1;i--) {
  371.         warray[i].hide();
  372.         dlay(18);
  373.         }
  374.     */
  375.     Twindow newerwindow;
  376.     newerwindow.init(4,3,77,18,0,3,1,7);
  377.     newerwindow.setborder(DOUBLE);
  378.     newerwindow.zoom();
  379.     newerwindow.divider(HOR,DOUBLE,2);
  380.     newerwindow.wprintc(1,14,3,"***  Features  ***");
  381.  
  382.     printc(7,0,3,"What you have just seen is just a small sampling of the power");
  383.     printc(8,0,3,"that you control using the Twindow class of the ObjectEase");
  384.     printc(9,0,3,"library. Here is a listing of some additional features:");
  385.     printc(11,15,3,"Change foreground and background colors");
  386.     printc(12,15,3,"Print to a specific window");
  387.     printc(13,15,3,"Specify shadow or no shadow");
  388.     printc(14,15,3,"Have the window tell you all of it's details");
  389.     printc(15,15,3,"Never fear corrupted or lost memory, as a Twindow");
  390.     printc(16,15,3,"frees all of its accociated memory when it leaves scope");
  391.     dlay(18*4);
  392.  
  393.     printc(25,15+128,1,"Press <ENTER> to continue...");
  394. getkey:
  395.     while(!kbhit());
  396.     ch=getch();
  397.     if(ch==27) {
  398.         clrscr();
  399.         exit(0);
  400.         }
  401.     if(ch!=13) {
  402.         flushkeys();
  403.         goto getkey;
  404.         }
  405. }
  406.  
  407. //**************************************************************************
  408. //              MENUDEMO
  409. //**************************************************************************
  410.  
  411. void menudemo()
  412. {
  413.     char ch;
  414.  
  415.     clear(32,1,1);
  416.     dlay(12);
  417.     smover(12,1,38,14,1,"Menus");
  418.     dlay(18*2);
  419.     smover(12,38,76,14,1,"Menus");
  420.     clear(176,15,1);
  421.     dlay(18);
  422.     clear(176,15,1);
  423.  
  424.     Twindow textwindow;
  425.     textwindow.init(5,3,76,15,15,3,1,7);
  426.     textwindow.setborder(DOUBLE);
  427.     textwindow.zoom();
  428.     textwindow.divider(HOR,DOUBLE,2);
  429.     textwindow.wprintc(1,14,3,"Menus");
  430.  
  431.     printc(7,15,3,"The Tmenu class is descended from the Twindow class,");
  432.     printc(8,15,3,"therefore inheriting all of the member functions of the");
  433.     printc(9,15,3,"Twindow class. To use a Tmenu instance in its simplest form");
  434.     printc(10,15,3,"simply pass it the structure containing your menu selections");
  435.     printc(11,15,3,"and capture the returned value. We won't go into details");
  436.     printc(12,15,3,"as with the Twindow class, but rest assured the Tmenu class");
  437.     printc(13,15,3,"is just as powerful and as easy to implement!");
  438.     dlay(18*5);
  439.     printc(25,15+128,1,"Press <ENTER> to continue...");
  440.  
  441. getkey:
  442.     while(!kbhit());
  443.     ch=getch();
  444.     if(ch==27) {
  445.         clrscr();
  446.         exit(0);
  447.         }
  448.     if(ch!=13) {
  449.         flushkeys();
  450.         goto getkey;
  451.         }
  452.  
  453.     clear(176,15,1);
  454.     Tmenu demomenu;
  455.     itemarray items;
  456.  
  457.     _fstrcpy(items[1],"Item number 1");
  458.     _fstrcpy(items[2],"Item number 2");
  459.     _fstrcpy(items[3],"Item number 3");
  460.     _fstrcpy(items[4],"Continue");
  461.  
  462.     demomenu.init(4,items,10,13,20,15,1,14,5,1,8);
  463.     demomenu.title("Sample");
  464.     Twindow the_window;
  465.     the_window.init(15,4,66,8,15,1,1,7);
  466.     the_window.zoom();
  467.     printc(6,14,1,"Go ahead, experiment with this sample menu.");
  468.  
  469.     int done=0;
  470.     while(!done) {
  471.     int choice=demomenu.show();
  472.         switch(choice) {
  473.             case 1: demomenu.cfgd(7);
  474.                     printat(50,13,15,1,"You chose 1");
  475.                     printf("\a");
  476.                     dlay(18);
  477.                     demomenu.cfgd(15);
  478.                     continue;
  479.             case 2: demomenu.cfgd(7);
  480.                     printat(50,13,15,1,"You chose 2");
  481.                     printf("\a");
  482.                     dlay(18);
  483.                     demomenu.cfgd(15);
  484.                     continue;
  485.             case 3: demomenu.cfgd(7);
  486.                     printat(50,13,15,1,"You chose 3");
  487.                     printf("\a");
  488.                     dlay(18);
  489.                     demomenu.cfgd(15);
  490.                     continue;
  491.             case 4: demomenu.cfgd(7);
  492.                     done=1;
  493.                     dlay(9);
  494.                     continue;
  495.             }//switch
  496.         }//done
  497.     demomenu.hide();
  498.     clear(176,15,1);
  499. }
  500.  
  501. //**************************************************************************
  502. //              MENUDEMO
  503. //**************************************************************************
  504.  
  505. void pulldowndemo()
  506. {
  507.     char ch;
  508.  
  509.     clear(32,1,1);
  510.     dlay(12);
  511.     smover(12,1,33,14,1,"Pulldown Menus");
  512.     dlay(18*2);
  513.     smover(12,33,67,14,1,"Pulldown Menus");
  514.     clear(176,15,1);
  515.     dlay(18);
  516.     clear(176,15,1);
  517.  
  518.     Twindow textwindow;
  519.     textwindow.init(5,3,76,15,15,3,1,7);
  520.     textwindow.setborder(DOUBLE);
  521.     textwindow.zoom();
  522.     textwindow.divider(HOR,DOUBLE,2);
  523.     textwindow.wprintc(1,14,3,"Pulldown Menus");
  524.  
  525.     printc(7,15,3,"Pulldown Menus are now a BREEZE to add to your programs!");
  526.     printc(8,15,3,"Just tell the menu object what you want it to display, and");
  527.     printc(9,15,3,"hook it up to a menubar object. Menubars can be activated");
  528.     printc(10,15,3,"from the keyboard or by a mouse action, and can also be");
  529.     printc(11,15,3,"navigated by either, or both methods. You have complete");
  530.     printc(12,15,3,"control over the values returned for the various menu");
  531.     printc(13,15,3,"options. This is even easier than in version 2.0!!!");
  532.     dlay(18*5);
  533.     printc(25,15+128,1,"Press <ENTER> to continue...");
  534.  
  535. getkey:
  536.     while(!kbhit());
  537.     ch=getch();
  538.     if(ch==27) {
  539.         clrscr();
  540.         exit(0);
  541.         }
  542.     if(ch!=13) {
  543.         flushkeys();
  544.         goto getkey;
  545.         }
  546.  
  547.     clear(176,15,1);
  548.  
  549.     menubar mb;
  550.     pulldown pd1,pd2,pd3;
  551.  
  552.     pd1.init(0,7,0,2,5,5);
  553.     pd1.set_option(0,"&Open",1);
  554.     pd1.set_option(1,"&Save",2);
  555.     pd1.set_option(2,"Save &As",3);
  556.     pd1.set_option(3,"-",0);
  557.     pd1.set_option(4,"&Continue",4);
  558.  
  559.     pd2.init(0,7,0,2,5,5);
  560.     pd2.set_option(0,"Cu&t",11);
  561.     pd2.set_option(1,"&Copy",12);
  562.     pd2.set_option(2,"-",0);
  563.     pd2.set_option(3,"&Paste",13);
  564.  
  565.     pd3.init(0,7,0,2,5,5);
  566.     pd3.set_option(0,"&Index",21);
  567.     pd3.set_option(1,"-",0);
  568.     pd3.set_option(2,"&About",22);
  569.  
  570.     mb.init(0,7,0,2);
  571.     mb.set_title(0,"&File",&pd1);
  572.     mb.set_title(1,"&Edit",&pd2);
  573.     mb.set_title(2,"&Help",&pd3);
  574.  
  575.     int done=0;
  576.     mb.display();
  577.     the_mouse.arm();
  578.     while(!done) {
  579.         if(mb.triggered()) {
  580.             if(mb.trackbar()==4) {
  581.                 done=1;
  582.                 continue;
  583.                 }
  584.             }
  585.         }
  586.     the_mouse.unarm();
  587. }
  588.  
  589. //**************************************************************************
  590. //              STRINGDEMO
  591. //**************************************************************************
  592.  
  593. void stringdemo()
  594. {
  595.     char ch;
  596.  
  597.     clear(32,1,1);
  598.     dlay(12);
  599.     smover(12,1,37,14,1,"Strings");
  600.     dlay(18*2);
  601.     smover(12,37,74,14,1,"Strings");
  602.     clear(176,15,1);
  603.  
  604.     Twindow the_window;
  605.     the_window.init(5,3,76,16,0,3,1,7);
  606.     the_window.setborder(DOUBLE);
  607.     the_window.zoom();
  608.     the_window.divider(HOR,DOUBLE,2);
  609.     printc(4,14,3,"String Input");
  610.  
  611.     printc(7,15,3,"The Tstring class is going to be your best friend. There is");
  612.     printc(8,15,3,"NO easier way to get user input in such a variety of formats.");
  613.     printc(9,15,3,"The Tstring class has two descendants, Tnumeral and Tdate");
  614.     printc(10,15,3,"which allow you to capture and convert any data type.");
  615.     printc(11,15,3,"Have you ever tried to design a form that would let the user");
  616.     printc(12,15,3,"move to any desired input field, up or down, back and forth?");
  617.     printc(13,15,3,"If you have, I'm sure you've met with the same frustration as");
  618.     printc(14,15,3,"most other programmers. Your headaches are now over...");
  619.     dlay(18*5);
  620.  
  621.     printc(25,15+128,1,"Press <ENTER> to continue");
  622. getkey:
  623.     while(!kbhit());
  624.     ch=getch();
  625.     if(ch==27) {
  626.         clrscr();
  627.         exit(0);
  628.         }
  629.     if(ch!=13) {
  630.         flushkeys();
  631.         goto getkey;
  632.         }
  633.     the_window.hide();
  634.     clear(176,15,1);
  635.  
  636.     Twindow formwindow;
  637.     formwindow.init(10,5,71,17,14,2,1,7);
  638.     formwindow.title("Input");
  639.     formwindow.show();
  640.  
  641.     Tstring lname;
  642.     Tstring fname;
  643.     Tstring address;
  644.     Tstring csz;
  645.     Tnumeral age;
  646.  
  647.     lname.init(40,7,15,0);
  648.     lname.setincolors(15,0);
  649.     fname.init(40,9,10,0);
  650.     fname.setincolors(15,0);
  651.     address.init(40,11,20,0);
  652.     address.setincolors(15,0);
  653.     csz.init(40,13,25,0);
  654.     csz.setincolors(15,0);
  655.     age.init(40,15,2,0);
  656.     age.setincolors(15,0);
  657.  
  658.     printc(2,14,1,"Try this one on for size...");
  659.     printc(3,14,1,"Notice that all of the standard editing keys are available.");
  660.  
  661.     printat(15,7,14,2,"Last name: ");
  662.     lname.show();
  663.     printat(15,9,14,2,"First name: ");
  664.     fname.show();
  665.     printat(15,11,14,2,"Address: ");
  666.     address.show();
  667.     printat(15,13,14,2,"City, State, Zip: ");
  668.     csz.show();
  669.     printat(15,15,14,2,"Age: ");
  670.     age.show();
  671.  
  672.     cursoron();
  673. getlname:
  674.     lname.get_form_input();
  675.     if(lname.uparrowhit())
  676.         goto getage;
  677.     if(lname.dnarrowhit())
  678.         goto getfname;
  679. getfname:
  680.     fname.get_form_input();
  681.     if(fname.dnarrowhit())
  682.         goto getaddress;
  683.     if(fname.uparrowhit())
  684.         goto getlname;
  685. getaddress:
  686.     address.get_form_input();
  687.     if(address.uparrowhit())
  688.         goto getfname;
  689.     if(address.dnarrowhit())
  690.         goto getcsz;
  691. getcsz:
  692.     csz.get_form_input();
  693.     if(csz.uparrowhit())
  694.         goto getaddress;
  695.     if(csz.dnarrowhit())
  696.         goto getage;
  697. getage:
  698.     age.get_form_input();
  699.     if(age.uparrowhit())
  700.         goto getcsz;
  701.     if(age.dnarrowhit())
  702.         goto getlname;
  703.  
  704.     cursoroff();
  705.     vprintat(35,20,15,1,"%s %s",fname.getstring(),lname.getstring());
  706.     vprintat(35,21,15,1,"%s",address.getstring());
  707.     vprintat(35,22,15,1,"%s",csz.getstring());
  708.     vprintat(35,23,15,1,"%d",age.getint());
  709.     dlay(18*2);
  710.  
  711.     formwindow.hide();
  712.     clear(176,15,1);
  713.  
  714.     the_window.zoom();
  715.     printc(5,14,3,"Additional features");
  716.     printc(7,15,3,"Force strings to all capitals");
  717.     printc(8,15,3,"Detect <ENTER>, <ESC>, <TAB>, <UP ARROW>, <DN ARROW>");
  718.     printc(9,15,3,"<HOME>, <END>, <BACKSPACE>, <DEL>, as well as mouse keypresses");
  719.     printc(10,15,3,"Return numerals as ints, floats, or longs");
  720.     printc(11,15,3,"Change the colors of the input fields");
  721.     printc(12,15,3,"Format and verify date fields");
  722.     dlay(18*5);
  723.  
  724.     flushkeys();
  725.     printc(25,15+128,1,"Press <ENTER> to continue...");
  726.     getch();
  727. }
  728.  
  729. //**************************************************************************
  730. //              BUTTONDEMO
  731. //**************************************************************************
  732.  
  733. void buttondemo()
  734. {
  735.     int done=0;
  736.     char ch;
  737.  
  738.     clear(32,1,1);
  739.     dlay(12);
  740.     smover(12,1,37,14,1,"Buttons");
  741.     dlay(18*2);
  742.     smover(12,37,74,14,1,"Buttons");
  743.     clear(176,15,1);
  744.     dlay(9);
  745.  
  746.     Twindow demowindow;
  747.     demowindow.init(5,3,76,18,15,3,1,7);
  748.     demowindow.setborder(DOUBLE);
  749.     demowindow.zoom();
  750.     demowindow.divider(HOR,DOUBLE,2);
  751.  
  752.     printc(4,14,3,"Buttons");
  753.  
  754.     printc(7,15,3,"Pushbuttons provide yet another easy way to get input from");
  755.     printc(8,15,3,"the users of your applications. There are times when a menu");
  756.     printc(9,15,3,"is just too much, and that's when a pushbutton can serve the");
  757.     printc(10,15,3,"purpose perfectly. Pushbuttons can be activated by any trigger");
  758.     printc(11,15,3,"you choose, but the most common trigger is the ALT key combined");
  759.     printc(12,15,3,"with the highlighted letter, or of course the mouse.");
  760.     printc(13,15,3,"Give these buttons a try to get a feel for their use...");
  761.  
  762.     Tbutton button1;
  763.     button1.init(20,15,"Button 1",1);
  764.     Tbutton button2;
  765.     button2.init(35,15,"Button 2",2);
  766.     Tbutton button3;
  767.     button3.init(50,15,"Continue",1);
  768.  
  769.     button1.show(3);
  770.     button2.show(3);
  771.     button3.show(3);
  772.  
  773.     while(!done) {
  774.         if(kbhit()) {
  775.             ch=getch();
  776.             if(altkey()) {
  777.                 ch=getch();
  778.                 switch(ch) {
  779.                     case ALTB:      button1.press(3);
  780.                                 while(altkey());
  781.                                 button1.show(3);
  782.                                 continue;
  783.                     case ALTU:      button2.press(3);
  784.                                 while(altkey());
  785.                                 button2.show(3);
  786.                                 continue;
  787.                     case ALTC:      button3.press(3);
  788.                                 while(altkey());
  789.                                 button3.show(3);
  790.                                 done=1;
  791.                                 continue;
  792.                     }
  793.                 }//if altkey
  794.             else
  795.                 flushkeys();
  796.             }//if kbhit
  797.         }//while
  798.     clear(176,15,1);
  799. }
  800.  
  801. //*************************************************************************
  802. //              CHECKBOXDEMO
  803. //*************************************************************************
  804.  
  805. void checkboxdemo()
  806. {
  807.     char ch;
  808.     int done=0;
  809.  
  810.     clear(32,1,1);
  811.     dlay(12);
  812.     smover(12,1,35,14,1,"Checkboxes");
  813.     dlay(18*2);
  814.     smover(12,35,71,14,1,"Checkboxes");
  815.     clear(176,15,1);
  816.     dlay(9);
  817.  
  818.     Twindow the_window;
  819.     the_window.init(5,3,76,19,15,3,1,7);
  820.     the_window.setborder(DOUBLE);
  821.     the_window.zoom();
  822.     the_window.divider(HOR,DOUBLE,2);
  823.     printc(4,14,3,"Checkboxes");
  824.  
  825.  
  826.     printc(7,15,3,"One final way to capture user input is through the use of");
  827.     printc(8,15,3,"checkboxes. Checkboxes can provide the user with a means of");
  828.     printc(9,15,3,"making multiple selections. All your program needs to do");
  829.     printc(10,15,3,"\"ask\" the checkbox if it has been checked or not. The");
  830.     printc(11,15,3,"POWER of the object! The spacebar or the mouse is generally");
  831.     printc(12,15,3,"the trigger to toggle a checkbox's state, however, you may");
  832.     printc(13,15,3,"employ any trigger you choose. Try these samples using the");
  833.     printc(14,15,3,"<TAB> key to move among the checkboxes. Check the CONTINUE");
  834.     printc(15,15,3,"box and press <ENTER> when done.");
  835.  
  836.     Tcheckbox check1;
  837.     check1.init(25,17,14,3);
  838.     Tcheckbox check2;
  839.     check2.init(40,17,14,3);
  840.     Tcheckbox check3;
  841.     check3.init(55,17,14,3);
  842.  
  843.     printat(15,17,15,3,"Check #1:");
  844.     check1.show();
  845.     printat(30,17,15,3,"Check #2:");
  846.     check2.show();
  847.     printat(45,17,15,3,"Continue:");
  848.     check3.show();
  849.  
  850.     cursoron();
  851.     check1.grabcursor();
  852.  
  853.     int active1=1,active2=0,active3=0;
  854.     while(!done) {
  855.         if(kbhit()) {
  856.             ch=getch();
  857.             if(ch!=32 && ch!=9 && ch!=13) {
  858.                 flushkeys();
  859.                 continue;
  860.                 }
  861.             if(ch==32) {
  862.                 if(active1) {
  863.                     if(check1.ischecked())
  864.                         check1.uncheck();
  865.                     else
  866.                         check1.check();
  867.                     }
  868.                 if(active2) {
  869.                     if(check2.ischecked())
  870.                         check2.uncheck();
  871.                     else
  872.                         check2.check();
  873.                     }
  874.                 if(active3) {
  875.                     if(check3.ischecked())
  876.                         check3.uncheck();
  877.                     else
  878.                         check3.check();
  879.                     }
  880.                 }//ch==32
  881.             if(ch==9) {
  882.                 if(active1) {
  883.                     check2.grabcursor();
  884.                     active1=0;
  885.                     active2=1;
  886.                     continue;
  887.                     }
  888.                 if(active2) {
  889.                     check3.grabcursor();
  890.                     active2=0;
  891.                     active3=1;
  892.                     continue;
  893.                     }
  894.                 if(active3) {
  895.                     check1.grabcursor();
  896.                     active3=0;
  897.                     active1=1;
  898.                     continue;
  899.                     }
  900.                 }//ch==9;
  901.             if(ch==13) {
  902.                 if(check3.ischecked()) {
  903.                     done=1;
  904.                     continue;
  905.                     }
  906.                 }
  907.             }//kbhit
  908.         }//!done
  909.     cursoroff();
  910.     clear(176,15,1);
  911.     dlay(18*1);
  912. }
  913.  
  914. //*************************************************************************
  915. //              LISTBOXDEMO
  916. //*************************************************************************
  917.  
  918. void listboxdemo()
  919. {
  920.     clear(32,1,1);
  921.     dlay(12);
  922.     smover(12,1,35,14,1,"List Boxes");
  923.     dlay(18*2);
  924.     smover(12,35,71,14,1,"List Boxes");
  925.     clear(176,15,1);
  926.     dlay(9);
  927.  
  928.     Twindow far *the_window=new Twindow;
  929.     the_window->init(5,3,76,15,15,3,1,7);
  930.     the_window->setborder(DOUBLE);
  931.     the_window->zoom();
  932.     the_window->divider(HOR,DOUBLE,2);
  933.     printc(4,14,3,"List Boxes");
  934.  
  935.  
  936.     printc(7,15,3,"List Boxes are an excellent way to get user input when the");
  937.     printc(8,15,3,"list of choices is longer than a menu can easily accomodate,");
  938.     printc(9,15,3,"or when you need the options to stay visible on the screen");
  939.     printc(10,15,3,"even after the user has made a selection. These list boxes");
  940.     printc(11,15,3,"are limited to 64K of data, but that's probably a lot more");
  941.     printc(12,15,3,"than you'll ever find yourself needing. They can be navigated");
  942.     printc(13,15,3,"using either the keyboard or the mouse.");
  943.  
  944.     listbox mylist;
  945.     mylist.init(35,18,5,15,1,0,3);
  946.     mylist.append_item("1      ");
  947.     mylist.append_item("2");
  948.     mylist.append_item("3");
  949.     mylist.append_item("4");
  950.     mylist.append_item("5");
  951.     mylist.append_item("6");
  952.     mylist.append_item("7");
  953.     mylist.append_item("8");
  954.     mylist.append_item("9");
  955.     mylist.append_item("10");
  956.     mylist.append_item("11");
  957.     mylist.append_item("12");
  958.     mylist.append_item("13");
  959.     mylist.append_item("14");
  960.     mylist.append_item("15");
  961.     mylist.append_item("16");
  962.     mylist.append_item("17");
  963.     mylist.append_item("18");
  964.     mylist.append_item("19");
  965.     mylist.append_item("Continue");
  966.  
  967.     mylist.reactivate();
  968.     int done=0;
  969.     flushkeys();
  970.     the_mouse.arm();
  971.     while(!done) {
  972.         mylist.tracklist();
  973.         if((_fstricmp(mylist.is_selected_string(),"Continue"))==0)
  974.             done=1;
  975.         }
  976.     the_mouse.unarm();
  977.     the_window->hide();
  978.     delete the_window;
  979.     clear(176,15,1);
  980. }
  981.  
  982. //*************************************************************************
  983. //              DIRBOXDEMO
  984. //*************************************************************************
  985.  
  986. void dirboxdemo()
  987. {
  988.     clear(32,1,1);
  989.     dlay(12);
  990.     smover(12,1,32,14,1,"Directory Boxes");
  991.     dlay(18*2);
  992.     smover(12,32,68,14,1,"Directory Boxes");
  993.     clear(176,15,1);
  994.     dlay(9);
  995.  
  996.     Twindow far *the_window=new Twindow;
  997.     the_window->init(5,3,76,17,15,3,1,7);
  998.     the_window->setborder(DOUBLE);
  999.     the_window->zoom();
  1000.     the_window->divider(HOR,DOUBLE,2);
  1001.     printc(4,14,3,"Directory Boxes");
  1002.  
  1003.  
  1004.     printc(7,15,3,"Directory boxes make it very easy for you, the programmer,");
  1005.     printc(8,15,3,"as well as the user of your programs, to select files and");
  1006.     printc(9,15,3,"file names for disk I/O. Directory boxes can be navigated");
  1007.     printc(10,15,3,"with either the keyboard or the mouse. To move between");
  1008.     printc(11,15,3,"the various components of a directory box via the keyboard,");
  1009.     printc(12,15,3,"use the TAB key. Press the OK button with the mouse, or");
  1010.     printc(13,15,3,"choose CTRL-ENTER from the keyboard to return the file name.");
  1011.     printc(14,15,3,"WARNING: THERE IS NO ERROR HANDLING IN THIS DEMO FOR DRIVES");
  1012.     printc(15,15,3,"THAT CONTAIN NO DISK. DO NOT SELECT A DRIVE THAT IS NOT READY!");
  1013.  
  1014.     dlay(18*5);
  1015.     printc(25,15+128,1,"Press <ENTER> to continue");
  1016.     flushkeys();
  1017.  
  1018. getkey:
  1019.     while(!kbhit());
  1020.     char ch=getch();
  1021.     if(ch==27) {
  1022.         clrscr();
  1023.         exit(0);
  1024.         }
  1025.     if(ch!=13) {
  1026.         flushkeys();
  1027.         goto getkey;
  1028.         }
  1029.  
  1030.     the_window->hide();
  1031.     delete the_window;
  1032.     clear(32,1,1);
  1033.     dirbox far *db=new dirbox;
  1034.     cursoron();
  1035.     the_mouse.arm();
  1036.     db->trackdir();
  1037.     delete db;
  1038.     the_mouse.unarm();
  1039.     cursoroff();
  1040. }
  1041.  
  1042.  
  1043. //**************************************************************************
  1044. //              TEXTMOUSEDEMO
  1045. //**************************************************************************
  1046.  
  1047. void textmousedemo()
  1048. {
  1049.     int done=0;
  1050.     char ch;
  1051.  
  1052.     Twindow top;
  1053.     top.init(1,1,80,4,15,1,0,0);
  1054.     top.zoom();
  1055.     printc(2,14,1,"OK, now let's put it all to use. If you have a mouse,");
  1056.     printc(3,14,1,"use it also to select any field or option you choose.");
  1057.  
  1058.     Twindow form;
  1059.     form.init(5,6,76,15,15,3,1,7);
  1060.     form.setborder(DOUBLE);
  1061.     form.show();
  1062.  
  1063.     Tstring lname;
  1064.     Tstring fname;
  1065.  
  1066.     Tbutton donebutton;
  1067.     donebutton.init(55,11," Complete ",2);
  1068.     Tcheckbox yesbox;
  1069.     yesbox.init(45,11,15,3);
  1070.     Tcheckbox nobox;
  1071.     nobox.init(45,13,15,3);
  1072.  
  1073.     printat(10,7,14,3,"First name: ");
  1074.     printat(10,9,14,3,"Last name:  ");
  1075.     fname.init(25,7,10,0);
  1076.     fname.setincolors(14,0);
  1077.     fname.show();
  1078.     lname.init(25,9,15,0);
  1079.     lname.setincolors(14,0);
  1080.     lname.show();
  1081.  
  1082.     printat(10,12,14,3,"Enjoying demo thus far?");
  1083.     printat(40,11,14,3,"Yes");
  1084.     printat(40,13,14,3,"No ");
  1085.     yesbox.show();
  1086.     nobox.show();
  1087.     yesbox.check();
  1088.  
  1089.     donebutton.show(3);
  1090.     the_mouse.arm();
  1091.     cursoron();
  1092.  
  1093.     while(!done) {
  1094. getfname:
  1095.         fname.get_form_mouse_input();
  1096.         if(the_mouse.LBP())
  1097.             goto checkmouse;
  1098.         if(fname.dnarrowhit() || fname.tabhit())
  1099.             goto getlname;
  1100.         if(fname.uparrowhit())
  1101.             goto getdone;
  1102. getlname:
  1103.         lname.get_form_mouse_input();
  1104.         if(the_mouse.LBP())
  1105.             goto checkmouse;
  1106.         if(lname.uparrowhit())
  1107.             goto getfname;
  1108.         if(lname.dnarrowhit() || lname.tabhit())
  1109.             goto getyes;
  1110. getyes:
  1111.         yesbox.grabcursor();
  1112.         while(!kbhit() && !the_mouse.LBP());
  1113.         if(the_mouse.LBP())
  1114.             goto checkmouse;
  1115.         ch=getch();
  1116.         if(ch==32) {
  1117.             if(yesbox.ischecked()) {
  1118.                 yesbox.uncheck();
  1119.                 nobox.check();
  1120.                 }
  1121.             else {
  1122.                 yesbox.check();
  1123.                 nobox.uncheck();
  1124.                 }
  1125.             }
  1126.         if(ch==9) {
  1127.             flushkeys();
  1128.             goto getno;
  1129.             }
  1130.         if(ch==0) {
  1131.             ch=getch();
  1132.             if(ch==80)
  1133.                 goto getno;
  1134.             if(ch==72)
  1135.                 goto getlname;
  1136.             flushkeys();
  1137.             }
  1138.         else {
  1139.             flushkeys();
  1140.             goto getyes;
  1141.             }
  1142. getno:
  1143.         nobox.grabcursor();
  1144.         while(!kbhit() && !the_mouse.LBP());
  1145.         if(the_mouse.LBP())
  1146.             goto checkmouse;
  1147.         ch=getch();
  1148.         if(ch==32) {
  1149.             if(nobox.ischecked()) {
  1150.                 nobox.uncheck();
  1151.                 yesbox.check();
  1152.                 }
  1153.             else {
  1154.                 nobox.check();
  1155.                 yesbox.uncheck();
  1156.                 }
  1157.             }
  1158.         if(ch==9) {
  1159.             flushkeys();
  1160.             goto getdone;
  1161.             }
  1162.         if(ch==0) {
  1163.             ch=getch();
  1164.             if(ch==80)
  1165.                 goto getdone;
  1166.             if(ch==72)
  1167.                 goto getyes;
  1168.             flushkeys();
  1169.             }
  1170.         else {
  1171.             flushkeys();
  1172.             goto getno;
  1173.             }
  1174.  
  1175. getdone:
  1176.         gotoxy(57,11);
  1177.         while(!kbhit() && ! the_mouse.LBP());
  1178.         if(the_mouse.LBP())
  1179.             goto checkmouse;
  1180.  
  1181.         ch=getch();
  1182.         if(altkey()) {
  1183.             ch=getch();
  1184.             if(ch==ALTC) {
  1185.                 donebutton.press(3);
  1186.                 while(altkey());
  1187.                 donebutton.show(3);
  1188.                 done=1;
  1189.                 continue;
  1190.                 }
  1191.             }
  1192.         if(ch==13) {
  1193.             donebutton.press(3);
  1194.             dlay(3);
  1195.             donebutton.show(3);
  1196.             done=1;
  1197.             continue;
  1198.             }
  1199.         if(ch==9)
  1200.             goto getfname;
  1201.         if(ch==0) {
  1202.             ch=getch();
  1203.             if(ch==72)
  1204.                 goto getno;
  1205.             if(ch==80)
  1206.                 goto getfname;
  1207.             flushkeys();
  1208.             }
  1209.  
  1210. checkmouse:
  1211.         if(the_mouse.LBP()) {
  1212.             if(fname.hit()) {
  1213.                 while(the_mouse.LBP());
  1214.                 goto getfname;
  1215.                 }
  1216.             if(lname.hit()) {
  1217.                 while(the_mouse.LBP());
  1218.                 goto getlname;
  1219.                 }
  1220.             if(yesbox.hit()) {
  1221.                 if(yesbox.ischecked()) {
  1222.                     yesbox.uncheck();
  1223.                     nobox.check();
  1224.                     while(the_mouse.LBP());
  1225.                     }
  1226.                 else {
  1227.                     yesbox.check();
  1228.                     nobox.uncheck();
  1229.                     while(the_mouse.LBP());
  1230.                     }
  1231.                 goto getyes;
  1232.                 }
  1233.             if(nobox.hit()) {
  1234.                 if(nobox.ischecked()) {
  1235.                     nobox.uncheck();
  1236.                     yesbox.check();
  1237.                     while(the_mouse.LBP());
  1238.                     }
  1239.                 else {
  1240.                     nobox.check();
  1241.                     yesbox.uncheck();
  1242.                     while(the_mouse.LBP());
  1243.                     }
  1244.                 goto getno;
  1245.                 }
  1246.             if(donebutton.buttonpressed()) {
  1247.                 donebutton.press(3);
  1248.                 while(the_mouse.LBP());
  1249.                 donebutton.show(3);
  1250.                 done=1;
  1251.                 continue;
  1252.                 }
  1253.             }
  1254.         }//while !done
  1255.     cursoroff();
  1256.     the_mouse.unarm();
  1257. }
  1258.  
  1259. //**************************************************************************
  1260. //              WRAPUP
  1261. //**************************************************************************
  1262.  
  1263. void wrapup()
  1264. {
  1265.     clear(32,1,1);
  1266.     dlay(12);
  1267.     smoved(36,1,12,14,1,"Summary");
  1268.     dlay(18*2);
  1269.     smoveu(36,12,1,14,1,"Summary");
  1270.     clear(176,15,1);
  1271.     dlay(9);
  1272.  
  1273.     Twindow summwindow;
  1274.     summwindow.init(4,3,77,19,14,2,1,7);
  1275.     summwindow.show();
  1276.     summwindow.divider(HOR,DOUBLE,2);
  1277.     summwindow.wprintc(1,15,2,"Text Mode Features");
  1278.  
  1279.     printc(7,14,2,"You have now seen the richness of the features available");
  1280.     printc(8,14,2,"in the text mode objects of the ObjectEase class library.");
  1281.     printc(9,14,2,"Understand that this demo does not allow for all of the member");
  1282.     printc(10,14,2,"functions to be demonstrated. You, the programmer, have total");
  1283.     printc(11,14,2,"control over every aspect of these objects. End the cycle of");
  1284.     printc(12,14,2,"re-inventing the wheel... use these objects to piece together");
  1285.     printc(13,14,2,"application after application maintaining consistency and ease");
  1286.     printc(14,14,2,"of use. Object oriented technology makes application development");
  1287.     printc(15,14,2,"so much easier for the programmer. You need to take advantage");
  1288.     printc(16,14,2,"of this power NOW, or be left behind in the 1990's!");
  1289.     dlay(18*8);
  1290.  
  1291.     printc(25,15+128,1,"Press <ENTER> to continue...");
  1292.     getch();
  1293. }
  1294.